-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a test to assert that migrations are ordered as we declared them #467
Conversation
4416404
to
2bb0a9f
Compare
Codecov Report
@@ Coverage Diff @@
## master #467 +/- ##
=======================================
Coverage 35.82% 35.82%
=======================================
Files 47 47
Lines 2892 2892
=======================================
Hits 1036 1036
Misses 1763 1763
Partials 93 93 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, other than the small corrections.
db/migration/migration_test.go
Outdated
// | ||
// https://github.com/rubenv/sql-migrate/blob/011dc47c6043b25483490739b61cabbc5da7ee9a/migrate.go#L216 | ||
// | ||
// In order to improve the visbility and to akwnoldge that the way we |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// In order to improve the visbility and to akwnoldge that the way we | |
// In order to improve the visibility and to acknowledge that the way we |
db/migration/migration_test.go
Outdated
// A possible solution is to write our own MigrationSet who won't do the | ||
// ordering. In the meantime I (gianarb) will start a conversation with library | ||
// maintainer to figure out how we can improve this. | ||
func TestMigrationAreOrderendInTheWayWeDeclaredThem(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func TestMigrationAreOrderendInTheWayWeDeclaredThem(t *testing.T) { | |
func TestMigrationsAreOrderendInTheWayWeDeclaredThem(t *testing.T) { |
db/migration/migration_test.go
Outdated
t.Fatal(err) | ||
} | ||
if len(declaredMigration) != len(orderedMigration) { | ||
t.Error("migrations have not the same number of elements. This should never happen.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Error("migrations have not the same number of elements. This should never happen.") | |
t.Error("Migrations do not have the same number of elements. This should never happen.") |
2bb0a9f
to
8ec9ce1
Compare
This tests is coming from this PR #466 We didn't fully understood how the migration library sorts migration before having to troubleshoot that PR. Even if we declare them in order as part of the GetMigrations function the library still applies quick sort on the migration ID to stay concurrency safe https://github.com/rubenv/sql-migrate/blob/011dc47c6043b25483490739b61cabbc5da7ee9a/migrate.goL216 In order to improve the visbility and to akwnoldge that the way we append migrations to GetMigrations is the same we get after the sorting we wrote this tests. Signed-off-by: Gianluca Arbezzano <[email protected]>
8ec9ce1
to
8face1a
Compare
This tests is coming from this PR
#466
We didn't fully understood how the migration library sorts migration
before having to troubleshoot that PR. Even if we declare them in order
as part of the GetMigrations function the library still applies quick
sort on the migration ID to stay concurrency safe
https://github.com/rubenv/sql-migrate/blob/011dc47c6043b25483490739b61cabbc5da7ee9a/migrate.goL216
In order to improve the visbility and to akwnoldge that the way we
append migrations to GetMigrations is the same we get after the sorting
we wrote this tests.
I will start a conversation with the lib maintainer to figure out how we can improve our current workflow.